home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / editor / snmp_0_1.zip / snmp-0.1 / aka / snmp / Operation.java < prev    next >
Text File  |  1997-06-09  |  2KB  |  114 lines

  1. /*
  2. Snmp Library
  3. Copyright (C) 1997 Alex Kowalenko Associates Pty Ltd. All rights reserved.
  4.  
  5. $Id: Operation.java,v 1.2 1997/05/08 13:04:47 alex Exp $
  6.  
  7. This software maybe be free distributed, any any form, without fee, 
  8. but may not be modified in any way without express permission of 
  9. the directors of Alex Kowalenko Associates Pty Ltd. 
  10.  
  11. Alex Kowalenko Associates Pty Ltd makes no representations or
  12. warranties about the suitabililty of the software, not even the
  13. implied warranty of merchantability or fitness for any particular
  14. purpose.    
  15. */
  16.  
  17. package aka.snmp;
  18.  
  19. /**
  20.  * Snmp Operations
  21.  * @see Pdu
  22.  * @version     $Id: Operation.java,v 1.2 1997/05/08 13:04:47 alex Exp $
  23.  * @author      Alex Kowalenko
  24.  */
  25.  
  26. public class Operation {
  27.  
  28.     final static byte VOID = 99;
  29.     final static byte GET =  0;
  30.     final static byte GET_NEXT = 1;
  31.     final static byte RESPONSE = 2;
  32.     final static byte SET = 3;
  33.     final static byte TRAP = 4;
  34.   
  35.   private byte _value;
  36.   
  37. /**
  38.  * Default constructor
  39.  */
  40.  
  41.   public Operation() {
  42.       _value = VOID;
  43.   };
  44.  
  45. /** 
  46.  * Constucts from a byte representation
  47.  */
  48.   
  49.   public Operation(byte theOperation) {
  50.       _value = theOperation;
  51.   };
  52.  
  53. /**
  54.  * Constructs from a string representation
  55.  */
  56.  
  57.   public Operation(String name) {
  58.       if(name.equals("get"))
  59.       _value = GET;
  60.       else if(name.equals("getnext")) 
  61.       _value = GET_NEXT;
  62.       else if(name.equals("response"))
  63.       _value = RESPONSE;
  64.       else if(name.equals("set"))
  65.       _value = SET;
  66.       else if(name.equals("trap"))
  67.       _value = GET;
  68.       else 
  69.       _value = VOID;
  70.   };
  71.  
  72. /**
  73.  * Returns the byte representation
  74.  */
  75.  
  76.   public byte value() {
  77.       return _value;
  78.   };
  79.  
  80. /**
  81.  * Returns the string representation
  82.  */
  83.  
  84.   public String toString() {
  85.       switch( _value) {
  86.     case GET: 
  87.       return "SNMP Get";
  88.     case GET_NEXT:
  89.       return "SNMP Get Next";
  90.     case RESPONSE:
  91.       return "Snmp Response";
  92.     case SET: 
  93.       return "SNMP Set";
  94.     case TRAP:
  95.       return "SNMP Trap";
  96.       }
  97.       //  case VOID:
  98.       // default:     
  99.       return "Unknown";
  100.   }
  101.  
  102. /**
  103.  * Test Harness
  104.  */
  105.   
  106.     static public void main(String args[]) {
  107.     Operation s = new Operation();
  108.     System.out.println(s);
  109.     s = new Operation(Operation.GET_NEXT);
  110.     System.out.println(s);
  111.     }
  112.  
  113. }
  114.